document.write("<script type='text/javascript' src='Common/Common.js'></script>"); //自动加载文件
CommonFileListRequertFile('Jquery');      //导入jquery
CommonFileListRequertFile('Layer');       //导入layer
CommonFileListRequertFile('Status');       //导入layer
/**
 * 登录类
 * @constructor
 */
function Login(){

    /**
     * 动作转发
     * @param msg 消息
     */
    this.getAction=function (msg) {
        message= JSON.parse(msg.data);
        var state=this.checkStatus(message.head);
        if(state===false){
            layer.msg(message.msg);
            return;
        }
        switch (message.head){
            case ProtocolApi.Protocol['WEB_USER_LOGIN']:
                this.UserLogin(message.msg);
                break;
        }
    };

    /**
     * 状态码检测
     * @param status
     * @returns {boolean}
     */
    this.checkStatus=function (status){

        if(status==ProtocolApi.Protocol['GAME_ERROR']){
            return false;
        }
        return true;
    };

    /**
     * 账户登录
     * @param msg 消息
     * @constructor
     */
    this.UserLogin=function (msg){
        var token=msg.data.token;
        localStorage.setItem('PhpGameSocketToken', token);
        localStorage.setItem('PhpGameSocketTokenTime', Date.parse(new Date())/1000);
        layer.msg('登录成功,请等待页面跳转');

        setInterval(function (){
            window.location.href='index.html';
        }, 1000);
    };


}